package gui;

	import org.eclipse.swt.SWT;
	import org.eclipse.swt.widgets.Display;
	import org.eclipse.swt.widgets.MessageBox;
	import org.eclipse.swt.widgets.Shell;

	/**
	 * class error message is used to open a message box with error message, all over the program
	 */
	public class ErrorMsg {

		/**
		 * c'tor- does nothing
		 */
		private ErrorMsg(){
			
		}
		
		/**
		 * singleton- using a static member insted of c'tor
		 */
		public static ErrorMsg instance = new ErrorMsg();
		
		public static ErrorMsg getInstance(){
			return instance;
		}
		
		
		/**
		 * open a shell of error msg
		 * @param str
		 */
		public void Error(final String str)
		{Thread massage = new Thread() {
		    public void run() {
		    	//open shell and display
			    Display disp = new Display();
			    final Shell shell = new Shell();
			    disp.syncExec(new Runnable() {
			        public void run() {	
			        	//write the message and display
			            MessageBox msg = new MessageBox(shell, SWT.ERROR);
			            msg.setText("Error");
			        	msg.setMessage(str);
			        	msg.open();	        	
									
			        }
			    });
			}
		};
		//start the massageBox
		massage.start();
		}




	}//end of class


